package day08.Regex_practice;

import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) {
        System.out.println("固定电话号码:");
        String s = new Scanner(System.in).nextLine();
        String regex = "(\\d{3,4}-|\\(\\d{3,4}\\))?\\d{7,8}";
        if (s.matches(regex)) {
            System.out.println("格式正确");
        } else {
            System.out.println("格式错误");
        }
    }
}
